package com.android.equipment.dao.operate;

import com.android.equipment.ObjectBox;
import com.android.equipment.dao.TeamGroup;

import java.util.List;

import io.objectbox.Box;

public class DaoTeamGroup {
    static Box<TeamGroup> teamGroupBox;
    private static DaoTeamGroup instance;

    private DaoTeamGroup() {
    }

    public static DaoTeamGroup getInstance() {
        if (instance == null) {
            instance = new DaoTeamGroup();
            teamGroupBox = ObjectBox.get().boxFor(TeamGroup.class);
        }
        return instance;
    }

    public long addTeamGroup(TeamGroup teamGroup) {
        return teamGroupBox.put(teamGroup);
    }

    public void deleteTeamGroup(TeamGroup teamGroup) {
        teamGroupBox.remove(teamGroup);
    }

    public void updateTeamGroup(TeamGroup teamGroup) {
        teamGroupBox.put(teamGroup);
    }

    public TeamGroup getTeamGroup(Long id) {
        return teamGroupBox.get(id);
    }

    public List<TeamGroup> getAllTeamGroup(){
        return teamGroupBox.getAll();
    }
}
